package com.vito.base.authoriza.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.vito.base.authoriza.dao.SectionMapper;
import com.vito.base.authoriza.service.SectionService;
import com.vito.base.model.DataGrid;
import com.vito.base.model.MyHashMap;
import com.vito.dcs.section.model.SectionModel;

@Service
public class SectionServiceImpl implements SectionService{

	@Autowired
	private SectionMapper sectionMapper;
	
	@Override
	public DataGrid<SectionModel> querySectionByPage(SectionModel sectionModel) {
		
		DataGrid<SectionModel> data = new DataGrid<SectionModel>();
		List<SectionModel> querySectionByPage = sectionMapper.querySectionByPage(sectionModel);
		data.setRows(querySectionByPage);
		data.setTotal(sectionModel.getTotal());
		return data;
	}

	@Override
	public List<SectionModel> queryWorkArea(SectionModel sectionModel) {
		return sectionMapper.queryWorkArea(sectionModel);
	}

	@Override
	public void deleteImpData(Map<String, Object> map) {
		sectionMapper.deleteBaseImport(map);
		sectionMapper.deleteBaseImportError(map);
	}

	@Override
	public Map<String, Object> saveValidateNew(Map<String, Object> map) {
		sectionMapper.saveValidateNew(map);
		return null;
	}

	@Override
	public Integer queryErrorCount(Map<String, Object> map) {
		return sectionMapper.queryErrorCount(map);
	}

	@Override
	public DataGrid<MyHashMap<String, Object>> queryImpMemberErrorByPage(
			Map<String, Object> map) {
		DataGrid<MyHashMap<String, Object>> data = new DataGrid<MyHashMap<String,Object>>();
		List<MyHashMap<String, Object>> list = sectionMapper.queryErrorItemByPage(map);
		Integer object = (Integer) map.get("total");
		data.setRows(list);
		data.setTotal(object);
		return data;
	}

	@Override
	public DataGrid<MyHashMap<String, Object>> queryMemberFromImportByPage(
			Map<String, Object> map) {
		DataGrid<MyHashMap<String, Object>> data = new DataGrid<MyHashMap<String,Object>>();
		List<MyHashMap<String, Object>> list = sectionMapper.queryMemberFromImportByPage(map);
		Integer object = (Integer) map.get("total");
		data.setRows(list);
		data.setTotal(object);
		return data;
	}

	@Override
	public Map<String, Object> saveImp(Map<String, Object> map) {
		sectionMapper.saveImp(map);
		return map;
	}

	@Override
	public List<Map<String, Object>> queryProjectTree(Map<String, Object> map) {
		return sectionMapper.queryProjectTree(map);
	}
	
	public String savePile(Map<String, Object> map) {
		
		//map.put("sectionId", "190402145423000012");
		//map.put("longitude", "114.11458028");
		//map.put("latitude", "35.038282587");
		
		sectionMapper.savePile(map);
		String str = (String) map.get("v_res_f");
		return str;
	}

	@Override
	public List<Map<String, Object>> queryAllGPS(Map<String, Object> map) {
		return sectionMapper.queryAllGPS(map);
	}

	@Override
	public String queryCurrentProcessType(Map<String, Object> map) {
		return sectionMapper.queryCurrentProcessType(map);
	}

	@Override
	public int queryIsHaveVehicle(SectionModel sectionModel) {
		return sectionMapper.queryIsHaveVehicle(sectionModel);
	}

	@Override
	public String savePile2(Map<String, Object> map) {
		sectionMapper.savePile2(map);
		String str = (String) map.get("v_res_f");
		return str;
	}

}
